package com.xhwl.logistics.service.business;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.logistics.bo.VehicleCardBO;
import com.xhwl.logistics.bo.input.PageBO;
import com.xhwl.logistics.bo.input.QueryVehicleCardBO;
import com.xhwl.logistics.converter.ToPage;
import com.xhwl.logistics.converter.mapstruct.VehicleCardConverter;
import com.xhwl.logistics.entity.VehicleCard;
import com.xhwl.logistics.service.impl.VehicleCardServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

//@Service
public class VehicleCardBusinessService {

    @Autowired
    private VehicleCardServiceImpl vehicleCardService;

    @Autowired
    private VehicleCardConverter vehicleCardConverter;

    @Autowired
    private ToPage toPage;

    public IPage<VehicleCardBO> queryCards(QueryVehicleCardBO queryVehicleCardBO, PageBO pageBO) {
        Page<VehicleCard> vehicleCardPage = vehicleCardService.page(pageBO.toPage(VehicleCard.class), vehicleCardService.conditionForQueryCards(queryVehicleCardBO.getProjectIdList(), queryVehicleCardBO.getCardType()));
        return toPage.toPage(vehicleCardPage, vehicleCardConverter.vehicleCardList2VehicleCardBOList(vehicleCardPage.getRecords()));
    }

    public List<VehicleCardBO> queryCards(QueryVehicleCardBO queryVehicleCardBO) {
        List<VehicleCard> vehicleCardList = vehicleCardService.list(vehicleCardService.conditionForQueryCards(queryVehicleCardBO.getProjectIdList(), queryVehicleCardBO.getCardType()));
        return vehicleCardConverter.vehicleCardList2VehicleCardBOList(vehicleCardList);
    }

}
